package org.example.ch09websocket.controller;

import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;



/**
 * @ClassName LoginServlet
 * @Description TODO
 * @Author Kx
 * @Date 2025/9/18 15:15
 * @Version 1.0
 */
@Controller
public class LoginController extends HttpServlet {
    /**
     * @author: kx
     * @date: 2025/9/19 11:49
     * @param user : 用户名
     * @param session : 会话对象
     * @description: 登录处理
    */
    @PostMapping("/login")
    protected String login(@RequestParam("user") String user, HttpSession session) {
        // 将用户信息存储到 session 中
        session.setAttribute("user", user);
        return "redirect:/chat.html";
    }
}
